home *** CD-ROM | disk | FTP | other *** search
- Path: tank.news.pipex.net!pipex!iol!usenet
- From: David Byrden <goyra@iol.ie>
- Newsgroups: comp.lang.c++
- Subject: Re: overloading ->
- Date: 16 Mar 1996 22:07:27 GMT
- Organization: Ireland On-Line
- Message-ID: <4ife2v$m8o@nuacht.iol.ie>
- References: <4id6o2$t5n@vixen.cso.uiuc.edu> <4ie274$pc1@sam.inforamp.net>
- NNTP-Posting-Host: dialup-184.dublin.iol.ie
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22KIT (Windows; I; 16bit)
-
-
- rmorin@inforamp.net (Randy Charles Morin) wrote:
- >In article <4id6o2$t5n@vixen.cso.uiuc.edu>,
- > wemccaug@prairienet.org (Wendy E. McCaughrin) wrote:
- >> I realize that in addition to returning an object pointer
- >> as value, a member operator -> can also return an object,
- >> but I am wondering if there is a way to overload it so it
- >> can return two different pointer types directly. My problem
- >> is that it has to be a member operator taking no arguments,
- >> so the different return-values would be the only distinction
- >> and, of course, that is not enough to make them regarded as
- >> different by the compiler. Any suggestions?
- >
- >Here's what I'm thinking. You have a primary class member function that
- >returns a secondary class. The secondary class has built-in implicit type
- >conversion routines that pass one value when converting to type x and another
- >when converting to type y.
- >
- >class Primary
- >{
- >public:
- > Secondary get(){Secondary s; s.i=0; s.c=0; return s;};
- >};
- >
- >class Secondary
- >{
- >public:
- > int i;
- > char c;
- >};
- >
-
- The primary class was supposed to have operator->() return something
- interesting, so a get() function is of no use.
-
- If operator-> returns an object with implicit conversions to two
- pointer types, what will make the choice between them?
-
-
- David
-
-
-